Dynomotion

Group: DynoMotion Message: 8500 From: eric_kato_sanders Date: 10/22/2013
Subject: ReadBit irregularity
Hi Tom,
I've writing my probing routine and had a tough time of it. My probe is a switch probe so when it is inactive, input 1 is held to ground.

What I found was the (ReadBit(pin) ^ polarity) logic would return zero at different points, even though the probe was inactive.

The logic works like this:

     MoveRelAtVel(axis, dist, vel);
     while (ReadBit(pin) ^ polarity) {
         if (CheckDone(axis))         {
             // Ran distance, no probe trigger
             ret = -1;
             break;
         }
      }
What I found that works is I had to add a WaitNextTimeSlice(); statement before I performed a ReadBit command.  This code works as I expect:
   while(TRUE)
   {
      if(CheckDone(axis))
      {
         ret = -1;
         break;
      }
      WaitNextTimeSlice();
      if(!(ReadBit(pin) ^ polarity))
      {
         break;
      }
   }

Tom, does this make sense that WaitNextTimeSlice() needs to be added?  Do I need WaitNextTimeSlice before CheckDone as well?
Eric
Group: DynoMotion Message: 8502 From: TK Date: 10/22/2013
Subject: Re: ReadBit irregularity
Hi Eric,

No it shouldn't be required. I suspect you have a noise problem. Adding the WaitNextTimeSlice() will check the input about 100 times less frequently. This would reduce the chances of detecting a noise glitch. 

How are things wired?  What type of input are you using?

A ceramic capacitor of ~0.1uF might be added near KFLOP to filter out noise.  Connected from the input to GND. 

Regards
TK

On Oct 22, 2013, at 7:29 AM, <eric@...> wrote:

 

Hi Tom,
I've writing my probing routine and had a tough time of it. My probe is a switch probe so when it is inactive, input 1 is held to ground.

What I found was the (ReadBit(pin) ^ polarity) logic would return zero at different points, even though the probe was inactive.

The logic works like this:

     MoveRelAtVel(axis, dist, vel);
     while (ReadBit(pin) ^ polarity) {
         if (CheckDone(axis))         {
             // Ran distance, no probe trigger
             ret = -1;
             break;
         }
      }
What I found that works is I had to add a WaitNextTimeSlice(); statement before I performed a ReadBit command.  This code works as I expect:
   while(TRUE)
   {
      if(CheckDone(axis))
      {
         ret = -1;
         break;
      }
      WaitNextTimeSlice();
      if(!(ReadBit(pin) ^ polarity))
      {
         break;
      }
   }

Tom, does this make sense that WaitNextTimeSlice() needs to be added?  Do I need WaitNextTimeSlice before CheckDone as well?
Eric

Group: DynoMotion Message: 8503 From: Hugh Sontag Date: 10/22/2013
Subject: Re: ReadBit irregularity
I had occasional noise, so I deglitched my inputs. The code is below:

int done = 0;
int homeCount = 0;
int limitCount = 0;

   while (! done) {   // loop until IO bit goes low
if (ReadBit(HOME_BIT_NUMBER) == 0) {
if (homeCount < 3) {
homeCount++;
} else {
printf("found Y HOME.\n");
done = 1;
}
} else {
homeCount = 0;
}
if (ReadBit(Y_LIMIT_BIT_NUMBER) == 0) {
if (limitCount < 3) {
limitCount++;
} else {
printf("found Y LIMIT.\n");
done = 1;
}
} else {
limitCount = 0;
}
WaitNextTimeSlice();
}

Hugh


On Tue, Oct 22, 2013 at 12:37 PM, TK <tk@...> wrote:
 

Hi Eric,

No it shouldn't be required. I suspect you have a noise problem. Adding the WaitNextTimeSlice() will check the input about 100 times less frequently. This would reduce the chances of detecting a noise glitch. 

How are things wired?  What type of input are you using?

A ceramic capacitor of ~0.1uF might be added near KFLOP to filter out noise.  Connected from the input to GND. 

Regards
TK

On Oct 22, 2013, at 7:29 AM, <eric@...> wrote:

 

Hi Tom,
I've writing my probing routine and had a tough time of it. My probe is a switch probe so when it is inactive, input 1 is held to ground.

What I found was the (ReadBit(pin) ^ polarity) logic would return zero at different points, even though the probe was inactive.

The logic works like this:

     MoveRelAtVel(axis, dist, vel);
     while (ReadBit(pin) ^ polarity) {
         if (CheckDone(axis))         {
             // Ran distance, no probe trigger
             ret = -1;
             break;
         }
      }
What I found that works is I had to add a WaitNextTimeSlice(); statement before I performed a ReadBit command.  This code works as I expect:
   while(TRUE)
   {
      if(CheckDone(axis))
      {
         ret = -1;
         break;
      }
      WaitNextTimeSlice();
      if(!(ReadBit(pin) ^ polarity))
      {
         break;
      }
   }

Tom, does this make sense that WaitNextTimeSlice() needs to be added?  Do I need WaitNextTimeSlice before CheckDone as well?
Eric


Group: DynoMotion Message: 8515 From: Tom Kerekes Date: 10/22/2013
Subject: Re: ReadBit irregularity
Hi Hugh,

I do worry that checking N times might just greatly reduce the probability of a false trigger on noise, the result might be a failure that occurs very infrequently.

But if the noise has a certain character like maximum frequency or certain periodicity (which is probably common) then it may well be 100% effective.

Just something to be aware of.

Regards
TK

Group: DynoMotion Message: 8517 From: Hugh Sontag Date: 10/22/2013
Subject: Re: ReadBit irregularity
I agree, if there was a possibility of a glitch that passed the glitch filter, it would have masked, rather than eliminated, the problem.

In my situation, I can report that the glitch filter is 100% effective, because it's used for E-stop and for limit switches. The limit switches used to cause an occasional fault which stopped all motion, but that no longer happens, with hours on the machine at this point. And the effect of the glitch filter on limit switch actuation or homing accuracy is negligible.

Generally, a rare glitch is likely to be a very short-duration event, and looking for it to exist across one or more time-slices is a valid way to eliminate its effect. In fact, the glitch filter is a digital analogue to a capacitor on the input (I have those, too.) Both of them reduce the sensitivity of the input to high frequency noise.

Hugh


On Tue, Oct 22, 2013 at 9:04 PM, Tom Kerekes <tk@...> wrote:
 

Hi Hugh,

I do worry that checking N times might just greatly reduce the probability of a false trigger on noise, the result might be a failure that occurs very infrequently.

But if the noise has a certain character like maximum frequency or certain periodicity (which is probably common) then it may well be 100% effective.

Just something to be aware of.

Regards
TK

Group: DynoMotion Message: 8521 From: eric_kato_sanders Date: 10/23/2013
Subject: Re: ReadBit irregularity

Thanks Tom.

I was very surprised when the cap fixed the problem because I was testing it on my bench with the only wiring being a parallel printer cable, (which has very good shielding), hooked up to the KFlop I/O.  When I get time, I'll have to hook up my scope to see what kind of noise profile I'm getting on the line.



---In DynoMotion@yahoogroups.com, <dynomotion@yahoogroups.com> wrote:

Hi Eric,

No it shouldn't be required. I suspect you have a noise problem. Adding the WaitNextTimeSlice() will check the input about 100 times less frequently. This would reduce the chances of detecting a noise glitch. 

How are things wired?  What type of input are you using?

A ceramic capacitor of ~0.1uF might be added near KFLOP to filter out noise.  Connected from the input to GND. 

Regards
TK

On Oct 22, 2013, at 7:29 AM, <eric@...> wrote:

 

Hi Tom,
I've writing my probing routine and had a tough time of it. My probe is a switch probe so when it is inactive, input 1 is held to ground.

What I found was the (ReadBit(pin) ^ polarity) logic would return zero at different points, even though the probe was inactive.

The logic works like this:

     MoveRelAtVel(axis, dist, vel);
     while (ReadBit(pin) ^ polarity) {
         if (CheckDone(axis))         {
             // Ran distance, no probe trigger
             ret = -1;
             break;
         }
      }
What I found that works is I had to add a WaitNextTimeSlice(); statement before I performed a ReadBit command.  This code works as I expect:
   while(TRUE)
   {
      if(CheckDone(axis))
      {
         ret = -1;
         break;
      }
      WaitNextTimeSlice();
      if(!(ReadBit(pin) ^ polarity))
      {
         break;
      }
   }

Tom, does this make sense that WaitNextTimeSlice() needs to be added?  Do I need WaitNextTimeSlice before CheckDone as well?
Eric